﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
///GetCookies 得到cookie集合信息
/// </summary>
public class GetCookies
{
    private static string strName = "zhwg_User";

    /// <summary>
    /// 用户id(编号)
    /// </summary>
    public static string UserIsn
    {
        get
        {
            //如果没有值不判断的话会报错 
            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[strName]["zhwg_Userisn"]);
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 用户ip地址
    /// </summary>
    public static string UserIP
    {
        get
        {
            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpContext.Current.Request.Cookies[strName]["zhwg_UserIP"];
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 用户名称
    /// </summary>
    public static string UserName
    {
        get
        {
            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[strName]["zhwg_UserRealName"]);
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 单位id(编号)
    /// </summary>
    public static string UnitIsn
    {
        get
        {
            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpContext.Current.Request.Cookies[strName]["zhwg_UnitIsn"];
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 单位名称
    /// </summary>
    public static string UnitName
    {
        get
        {
            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[strName]["zhwg_UserUnit_cn"]);
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 系统类型(bs/cs)
    /// </summary>
    public static string Model
    {
        get
        {

            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpContext.Current.Request.Cookies[strName]["zhwg_Model"];
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 前台checkbox选中状态(是否为值班员)
    /// </summary>
    public static string Watch
    {
        get
        {

            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpContext.Current.Request.Cookies[strName]["zhwg_Duty"];
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 所属节点id
    /// </summary>
    public static string NodeID
    {
        get
        {
            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpContext.Current.Request.Cookies[strName]["zhwg_Nodeid"];
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 所属节点名称
    /// </summary>
    public static string NodeName
    {
        get
        {

            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[strName]["zhwg_Nodeid_cn"]);
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 资源节点id,形式为'9701','9702'
    /// </summary>
    public static string UserNodeID
    {
        get
        {

            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpContext.Current.Request.Cookies[strName]["zhwg_UserResNodeid"];
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 用户组id,形式为1,2,3,......,
    /// </summary>
    public static string UserGroupIsn
    {
        get
        {

            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpContext.Current.Request.Cookies[strName]["zhwg_UserGroupisn"];
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 用户对哪些网有权限访问
    /// </summary>
    public static string NetWork
    {
        get
        {

            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpContext.Current.Request.Cookies[strName]["zhwg_NetWork"];
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 用户所属单位类型
    /// </summary>
    public static string UserUnitSort
    {
        get
        {

            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[strName]["zhwg_userUnitSort"]);
            }

            return string.Empty;
        }
    }

    /// <summary>
    /// 用户节点等级
    /// </summary>
    public static string UserNodeLevel
    {
        get
        {
            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpContext.Current.Request.Cookies[strName]["zhwg_userNodeLevel"];
            }

            return string.Empty;
        }
    }
    /// <summary>
    /// 用户节点等级
    /// </summary>
    public static string UserMAC
    {
        get
        {
            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpContext.Current.Request.Cookies[strName]["zhwg_UserMac"];
            }

            return string.Empty;
        }
    }
    /// <summary>
    /// GEOSERVER IP
    /// </summary>
    public static string GeoServerIP
    {
        get
        {
            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpContext.Current.Request.Cookies[strName]["GeoServerIP"];
            }

            return string.Empty;
        }
    }
    /// <summary>
    /// WEB IP
    /// </summary>
    public static string WebServerIP
    {
        get
        {
            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                return HttpContext.Current.Request.Cookies[strName]["WebServerIP"];
            }

            return string.Empty;
        }
    }
    /// <summary>
    /// 是否值班
    /// </summary>
    public static string IsDuty
    {
        get
        {
            string duty = string.Empty;
            if (HttpContext.Current.Request.Cookies[strName] != null)
            {
                duty = HttpContext.Current.Request.Cookies[strName]["zhwg_Duty"];
                if (duty == "false")
                {
                    return "0";
                }
                else
                {
                    return "1";
                }
            }
            return string.Empty;
        }
    }
}
